<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>天天生鲜-商品详情</title>
    <link rel="stylesheet" type="text/css" href="css/reset.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
    <script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="js/payfor.js"></script>
</head>
<body>

<#--<script>-->
    <#--function gotoshopcart(id1,num1,total1) {-->
        <#--//获取id-->
        <#--var id1=document.getElementById("goodsid").value;-->
        <#--var num1=document.getElementById("qty_item_1").value;-->
        <#--var a=document.getElementById("total_item_1").innerHTML;-->
        <#--var total1 = a.slice(1);-->
        <#--//alert(id1+" "+num1+" "+a);-->

       <#--location.href = "addShopCart?id=" + id1+"&goods_number="+num1+'&goods_subtotal='+total1;-->
    <#--}-->
<#--</script>-->
<script>
    function gotoshopcart(goods_id,goods_number,goods_subtotal) {
        var goods_id=document.getElementById("goodsid").value;
        var goods_number=document.getElementById("qty_item_1").value;
        var a=document.getElementById("total_item_1").innerHTML;
        var goods_subtotal = a.slice(1);

        $.ajax({
            url: "/addShopCart", //后端地址
            type: "post",       //提交方式
            data: {goods_id:goods_id,goods_number:goods_number,goods_subtotal:goods_subtotal
                //向后台提交的数据
            },
            dataType: "JSON",       //规定请求成功后返回的数据
            success: function (data) {
                //请求成功之后进入该方法，data为成功后返回的数据
                if (data.flag==0){
                    alert("您尚未登录，请先登录");
                    location.href="login";
                } else if (data.flag==1) {
                    alert("添加购物车成功")
                }else if (data.flag==3){
                    alert("添加购物车失败")
                }

            },
            error: function (errorMsg) {
                //请求失败之后进入该方法，errorMsg为失败后返回的错误信息
            }
        });
    }
    function gotoList() {
        location.href="GoodsList";
    }
    function gotocart() {
        location.href="shopcar";
    }
    function  gotoinfo() {
        location.href="user_center_info"
    }
    function UserOrder() {
        location.href = "user_center_order" ;
    }
</script>


<#--<script>
    function gotocart(id1,num1,total1) {
    // 加入购物车操作
   // $("#add_cart").click(function(){
        // 前端对数据进行校验(略)
        $.ajax({
            "url":"/",
            "data":{
                "gid":$("#goodsid").val(),
                "num":$("#qty_item_1").val(),
                "subtotal":$("#total_price").val().slice(1)
            },
            "type":"post",
            "dateType":"json",
            "success":function(data){
                if(data.state==200){
                    alert("添加入购物车成功!");
                }else{
                    alert(data.message);
                }
            },
            "error":function(){
                alert("您尚未登录或您的登录信息已过期，请重新登录!");
            }
        });
    // });
    }
</script>-->



<div class="header_con">
    <div class="header">
        <div class="welcome fl">欢迎来到天天生鲜!</div>
        <div class="fr">
            <div class="login_info fl">
                欢迎您：<em>张 山</em>
            </div>
            <div class="login_btn fl">
                <a href="login.html">登录</a>
                <span>|</span>
                <a href="register.html">注册</a>
            </div>
            <div class="user_link fl">
                <span>|</span>
                <a href="javascript:gotoinfo()">用户中心</a>
                <span>|</span>
                <a href="javascript:gotocart()">我的购物车</a>
                <span>|</span>
                <a href="javascript:UserOrder()">我的订单</a>
            </div>
        </div>
    </div>
</div>

<div class="search_bar clearfix">
    <a href="index.html" class="logo fl"><img src="images/logo.png"></a>
    <div class="search_con fl">
        <input type="text" class="input_text fl" name="" placeholder="搜索商品">
        <input type="button" class="input_btn fr" name="" value="搜索">
    </div>
    <div class="guest_cart fr">
        <a href="cart.html" class="cart_name fl">我的购物车</a>
        <div class="goods_count fl" id="show_count">1</div>
    </div>
</div>

<div class="navbar_con">
    <div class="navbar clearfix">
        <div class="subnav_con fl">
            <h1>全部商品分类</h1>
            <span></span>
            <ul class="subnav">
                <li><a href="#" class="fruit">新鲜水果</a></li>
                <li><a href="#" class="seafood">海鲜水产</a></li>
                <li><a href="#" class="meet">猪牛羊肉</a></li>
                <li><a href="#" class="egg">禽类蛋品</a></li>
                <li><a href="#" class="vegetables">新鲜蔬菜</a></li>
                <li><a href="#" class="ice">速冻食品</a></li>
            </ul>
        </div>
        <ul class="navlist fl">
            <li><a href="">首页</a></li>
            <li class="interval">|</li>
            <li><a href="javascript:gotoList()">手机生鲜</a></li>
            <li class="interval">|</li>
            <li><a href="">抽奖</a></li>
        </ul>
    </div>
</div>

<div class="breadcrumb">
    <a href="#">全部分类</a>
    <span>></span>
    <a href="#">新鲜水果</a>
    <span>></span>
    <a href="#">商品详情</a>
</div>
<form action="" method="post">
<div class="goods_detail_con clearfix">

        <input type="hidden" id="goodsid" name="goods_id" value="${Request.goods.goods_id}" />
    <div class="goods_detail_pic fl"><img style="height: 350px;width: 350px" src="images/${Request.goods.goods_picture}"></div>

    <div class="goods_detail_list fr">
        <h3 >${Request.goods.goods_name}</h3>
        <p>${Request.goods.goods_info}</p>
        <div class="prize_bar">
            <span class="show_pirze">¥<em id="price_item_1" >${Request.goods.goods_price}</em></span>
            <span class="show_unit" >单  位：${Request.goods.goods_unit}</span>
        </div>

        <div class="goods_num clearfix">
            <div class="num_name fl">数 量：</div>

           <div class="num_add fl">
                <input type="text"  class="num_show fl" value="1" name="qty_item_1" id="qty_item_1" onKeyUp="setAmount.modify('#qty_item_1')">
                <a href="javascript:;"  class="add fr" onClick="setAmount.add('#qty_item_1')">+</a>
                <a href="javascript:;" class="minus fr" onClick="setAmount.reduce('#qty_item_1')">-</a>
            </div>
            <div class="num_name fl" style="margin-left: 30px">库存：${Request.goods.goods_number}</div>
        </div>

        <div class="total">总价：<em id="total_item_1"></em><input type="hidden" name="goods_subtotal" id="total_price" value="" /></div>

        <div class="operate_btn">
            <a href="javascript:;" class="buy_btn">立即购买</a>
            <a href="javascript:gotoshopcart();" class="add_cart" id="add_cart" >加入购物车</a>
        </div>

    </div>

</div>
</form>
<div class="main_wrap clearfix">
    <div class="l_wrap fl clearfix">
        <div class="new_goods">
            <h3>新品推荐</h3>
            <ul>
                <li>
                    <a href="#"><img src="images/goods/goods001.jpg"></a>
                    <h4><a href="#">进口柠檬</a></h4>
                    <div class="prize">￥3.90</div>
                </li>
                <li>
                    <a href="#"><img src="images/goods/goods002.jpg"></a>
                    <h4><a href="#">玫瑰香葡萄</a></h4>
                    <div class="prize">￥16.80</div>
                </li>
            </ul>
        </div>
    </div>

    <div class="r_wrap fr clearfix">
        <ul class="detail_tab clearfix">
            <li class="active">商品介绍</li>
            <li>评论</li>
        </ul>

        <div class="tab_content">
            <dl>
                <dt>商品详情：</dt>
                <dd>${goods.goods_introduce}</dd>
            </dl>
        </div>

    </div>
</div>

<div class="footer">
    <div class="foot_link">
        <a href="#">关于我们</a>
        <span>|</span>
        <a href="#">联系我们</a>
        <span>|</span>
        <a href="#">招聘人才</a>
        <span>|</span>
        <a href="#">友情链接</a>
    </div>
    <p>CopyRight © 2016 北京天天生鲜信息技术有限公司 All Rights Reserved</p>
    <p>电话：010-****888    京ICP备*******8号</p>
</div>
<div class="add_jump"></div>

<script type="text/javascript" src="js/jquery-1.12.2.js"></script>
<script type="text/javascript">
    var $add_x = $('#add_cart').offset().top;
    var $add_y = $('#add_cart').offset().left;

    var $to_x = $('#show_count').offset().top;
    var $to_y = $('#show_count').offset().left;

    $(".add_jump").css({'left':$add_y+80,'top':$add_x+10,'display':'block'})
    $('#add_cart').click(function(){
        $(".add_jump").stop().animate({
                'left': $to_y+7,
                'top': $to_x+7},
            "fast", function() {
                $(".add_jump").fadeOut('fast',function(){
                    $('#show_count').html(2);
                });

            });
    })
</script>

</body>
</html>